<?php


namespace app\admin\controller;

use think\facade\Session;
use think\Request;

class CheckPass
{
    // 登录验证
    public function checkLogin(Request $request){
        $admin = new Admin();
        $data = $admin->selectPassword($request->post("account"));

        // 查不到数据，没有此用户
        if($data != null){$password = $data['admin_password'];}
        else{return redirect("/admin/login");}
        // 验证密码正确不正确
        if($password == $request->post('password') &&
            $password != null &&
            $request->post('password') !=null){
            Session::set("admin",$request->post("account"));
            return redirect("/admin");
        }else{
            return redirect("/admin/login");
        }
    }
}